Strict

Import agfx

Class TRectangle Extends TPrimitive
	
	Field type:Int = -1
	
	Method New()
		Super.New(PRIMITIVE_TYPE_RECTANGLE)
	End Method
	
	Method Create:Void(A:TVector2,B:TVector2,C:TVector2,D:TVector2)
		Self.points.Add(A)
		Self.points.Add(B)
		Self.points.Add(C)
		Self.points.Add(D)		
		Self.Update()				
	End Method
	
	Method Create:Void(pos:TVector2,size:TVector2)
		Local A:TVector2 = New TVector2(pos.x,pos.y)
		Local B:TVector2 = New TVector2(pos.x+size.x,pos.y)
		Local C:TVector2 = New TVector2(pos.x+size.x,pos.y+size.y)
		Local D:TVector2 = New TVector2(pos.x,pos.y+size.y)
		Self.Create(A,B,C,D)			
	End Method
	
	Method Create:Void(size:TVector2)
		Local A:TVector2 = New TVector2(0,0)
		Local B:TVector2 = New TVector2(size.x,0)
		Local C:TVector2 = New TVector2(size.x,size.y)
		Local D:TVector2 = New TVector2(0,size.y)
		Self.Create(A,B,C,D)			
	End Method
	
	
	Method Update:Void(recalc_center:Bool=True,recalc_bbox:Bool=True,recalc_edge:Bool=True)
		
		If recalc_edge Then Self.CalcEdges()
		If recalc_center Then Self.CalcCenter()
		If recalc_bbox Then Self.CalcBoundingBox()
		
	End Method
End Class